#ifndef __STEER_H__
#define __STEER_H__

// #include "tim.h"
#include "main.h"

#include "FreeRTOS.h"
#include "task.h"

#include "my_lib/my_log.h"
#include "my_lib/cmd_analyse.h"


// #define HORIZONTAL_STEER_TIM      htim4
// #define HORIZONTAL_STEER_CHANNEL  TIM_CHANNEL_1
// #define VERTICAL_STEER_TIM      htim4
// #define VERTICAL_STEER_CHANNEL  TIM_CHANNEL_2


#define MIN_ANGLE_DUTY_CCR  (0.5*1000)  //最小角度0.5ms
#define MAX_ANGLE_DUTY_CCR  (2.5*1000)  //最大角度2.5ms

#define ANGLE_ADD_TIME  5    //角度步进变化间隔时间

//舵机属性
#define HORIZONTAL_STEER_MECHANICAL_ANGLE 180  //舵机自身角度范围
#define HORIZONTAL_STEER_INIT_ANGLE  93
#define HORIZONTAL_STEER_MIN_ANGLE   0
#define HORIZONTAL_STEER_MAX_ANGLE   180
#define HORIZONTAL_STEER_STEP_ANGLE  1

#define VERTICAL_STEER_MECHANICAL_ANGLE 180
#define VERTICAL_STEER_INIT_ANGLE  93
#define VERTICAL_STEER_MIN_ANGLE   70
#define VERTICAL_STEER_MAX_ANGLE   120
#define VERTICAL_STEER_STEP_ANGLE  1

typedef enum
{
    HorizontalSteer = 0,
    VerticalSteer,
}steer_id_enum_t;

typedef struct 
{
    float tar_angle;
    float pre_angle;
    // float init_angle;
    float min_angle;
    float max_angle;
    float step_angle;  //角度步进变化值
    uint8_t state;  //舵机是否需要工作标志位
}steer_t;


extern steer_t steers[2];
// void SteerTask(void* param);
void SteerTask(void* param);
void SetSteerAngle(steer_id_enum_t steer_id, double angle);
void SteerAngle2PWM(steer_id_enum_t steer_id, double angle);

#endif

